package umls.geneus.server;

import it.polito.dao.DataNotFoundException;
import it.polito.dao.GeneusDao;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.jws.WebParam;
import javax.jws.WebService;

import org.apache.log4j.PropertyConfigurator;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.dao.DataAccessException;

import spring.context.GeneusContext;
import umls.geneus.core.Geneus;
import umls.interfaces.pubmed.server.jaxws.AbstractSummary;
import umls.interfaces.pubmed.server.jaxws.Percentili;
import umls.interfaces.pubmed.server.jaxws.PubProxy;
import umls.interfaces.pubmed.server.jaxws.ServerException_Exception;
import umls.interfaces.pubmed.server.jaxws.Synonym;

@WebService(targetNamespace = "http://jaxws.server.pubmed.interfaces.umls/", name = "PubProxy")
public class FusionGeneus implements PubProxy {
	SessionFactory sessionFactory = null;
	ApplicationContext context = null;
	 
	 public FusionGeneus() throws IOException{
		 PropertyConfigurator.configure("bin/log4j.properties");
		 context = GeneusContext.getApplicationContext();
		 GeneusDao dao = context.getBean("GeneusDao",GeneusDao.class);
		 Geneus g = context.getBean("Geneus",Geneus.class);
		dao.saveAbstract("ciao", "abstr");
		try {
			System.out.println(dao.getAbstract("ciao"));
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (DataNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		List<String> expanGroups = new ArrayList<String>(5);
			expanGroups.add("CHEM");
			expanGroups.add("GENE");
			expanGroups.add("ANAT");
			expanGroups.add("PHYS");
			expanGroups.add("ACTI");
	//	List<String> s= g.expandedSearch("angiogenesis", "vegfa",expanGroups );
	//		System.out.println(s.size()+""+ s);
			
	 }
	@Override
	public List<Percentili> getPercentili(
	        @WebParam(name = "process", targetNamespace = "")
	        String process,
	        @WebParam(name = "gene", targetNamespace = "")
	        String gene,
	        @WebParam(name = "p_weight", targetNamespace = "")
	        int pWeight, 
	        @WebParam(name = "expan_groups", targetNamespace = "")
	        List<String> expanGroups,
	        @WebParam(name = "score_groups", targetNamespace = "")
	        List<String> scoreGroups)
	        throws ServerException_Exception {
		
		return null;
	}

	@Override
	public int getAffinity(
			@WebParam(name = "process", targetNamespace = "") String process,
			@WebParam(name = "genes", targetNamespace = "") String gene)
			throws ServerException_Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Synonym> getSynonymsAUI(
			@WebParam(name = "term", targetNamespace = "") String term)
			throws ServerException_Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getUMLSDef(
			@WebParam(name = "term", targetNamespace = "") String term)
			throws ServerException_Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public AbstractSummary getPubmedDoc(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getMetaMapData(String term) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getRelevantDocs(
	        @WebParam(name = "gene", targetNamespace = "")
	        String gene,
	        @WebParam(name = "process", targetNamespace = "")
	        String process,
	        @WebParam(name = "expan_groups", targetNamespace = "")
	        List<String> expanGroups,
	        @WebParam(name = "score_groups", targetNamespace = "")
	        List<String> scoreGroups)
	        throws ServerException_Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
